{include file="public/header" /}

<!--<body style="background-image:url(/dist/img/xjddLogo.png);background-repeat:no-repeat; background-size:100% 100%;-moz-background-size:100% 100%;">-->
<link rel="stylesheet" href="__CSS__/login.css" media="all">
<body style="background-image:url(/dist/imgs/bg3.jpg);background-repeat:no-repeat; background-size:100% 100%;-moz-background-size:100% 100%;">
<div class="layadmin-user-login layadmin-user-display-show content" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main" style="margin-top:5%;background: #FFFFFF;border-radius: 15px;padding:15px 0 15px 0; width:;">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <div class="title">{$title}</div>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">

            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-cellphone" for="LAY-user-login-username"></label>
                <input type="text" name="Mobile" id="LAY-user-login-Mobile" placeholder="账户或手机号" class="layui-input">
                <input type="hidden" name="Mac" id="mac" value=""  class="layui-input">
            </div>

            <div class="layui-form-item layui-hide mobile-box">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                        <input type="text" name="Code" id="Code" placeholder="图形验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <img src="{:url('admin/Login/verify')}" alt="" onclick='this.src=this.src+"?c="+Math.random()' style="width: 100%;height: 100%;"/>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide mobile-box">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
                        <input type="text" name="MsgCode" placeholder="短信验证码" class="layui-input">
                    </div>
                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <button type="button" class="layui-btn layui-btn-primary layui-btn-fluid" id="codeText" onclick="verifys()">获取验证码</button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item layui-hide password-box">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-username"></label>
                <input type="password" name="Password" placeholder="请输入密码" class="layui-input">
            </div>

            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 陆</button>
            </div>
        </div>
    </div>

</div>
</body>
<script src="__CSS__/layuiAdmin/layui/layui.js"></script>
<script src="__CSS__/jquery/jquery-3.3.1.min.js"></script>
<script src="http://cdn.highcharts.com.cn/highcharts/highcharts.js"></script>

<script>
    layui.config({
        base: '__CSS__/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'console','sample']);
</script>
<script>
    layui.use(['index', 'user'], function() {
        var $ = layui.$,
            admin = layui.admin,
            form = layui.form,
            router = layui.router(),
            search = router.search;

        form.render();
        //提交
        form.on('submit(LAY-user-login-submit)', function(obj) {
            $.ajax({
                url:"{:url('admin/login/login')}",
                type:'POST',
                data:obj.field,
                success:function(res){
                    if(res.code == 200){
                        layer.msg(res.msg);
                        window.setTimeout(function(){
                            window.location.href = "{:url('admin/count/default')}";
                        }, 2000);
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
        });
    });

    //获取登陆方式
    $("input[name='Mobile']").blur(function(){
        var Mobile = $.trim($(this).val());
        $.ajax({
            url:"{:url('admin/login/getLoginType')}",
            type:"post",
            data:{'Mobile':Mobile},
            success:function(res){
                if(res.code == 200){
                    if(res.data == 1){
                        $(".mobile-box").removeClass('layui-hide');
                        $(".password-box").addClass('layui-hide');
                    }else if(res.data == 2){
                        $(".password-box").removeClass('layui-hide');
                        $(".mobile-box").addClass('layui-hide');
                    }else{
                        layer.msg('登陆方式错误，请联系管理');
                    }
                }else{
                    layer.msg(res.msg);
                }
            }
        })
    });

    var isBtn = 1;//按钮可点击状态
    var time  = 60;//读秒时间值

    function verifys(){
        if(isBtn == 1){
            $.ajax({
                url:"{:url('admin/login/sendVerify')}",
                type:'POST',
                data:{'Mobile':$('#LAY-user-login-Mobile').val(),"mac":$('#mac').val(),'Code':$("#Code").val()},
                success:function(res){
                    console.log(res);
                    if(res.code == 200){
                        layer.msg('验证码已发送');
                        setTime();
                    }else{
                        layer.msg(res.msg);
                    }
                }
            })
        }else{
            layer.msg('请'+time+'s后重发');
        }
    };

    //读秒
    function setTime(){
        isBtn = 0;
        timer = setInterval(function(){
            time--;
            if(time <= 0){
                isBtn = 1;
                time = 60;
                clearInterval(timer);
                $("#codeText").text('获取验证码');
            }else{
                var str = time + "s后重发";
                $("#codeText").text(str);
            }
        },1000);
    }
</script>